/*
 * sharedmemory.h
 *
 *  Created on: Mar 11, 2012
 *      Author: our_beastie
 */

#ifndef SHAREDMEMORY_H_
#define SHAREDMEMORY_H_


#include "queue.h"
#include "process.h"

#define DEFAULT_MIN_VALUE 0
#define DEFAULT_MAX_VALUE 1

struct CPUStr;
typedef struct CPUStr* CPU_MEM;

typedef struct {
	CPU_MEM cpu;
	int semaphore;
	int max;
	int min;
	pthread_mutex_t mutex_semaphore;
	Queue block_queue;

} MemoryStr;

typedef MemoryStr* Memory;

Memory newMemory(CPU_MEM cpu, int max_processes);
void incrementMemory(Memory memory, Process p);

void decrementMemory(Memory memory, Process p);

#endif /* SHAREDMEMORY_H_ */
